package com.wangshaoyu.music_player.repository;

import com.wangshaoyu.music_player.data_object.UserDo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface UserRepo {
    @Insert("insert into users (username, password) values (#{username}, #{password})")
    @Options(useGeneratedKeys = true, keyColumn = "uid", keyProperty = "uid")
    void insert(UserDo userDo);

    @Select("select uid, username, password from users where username = #{username}")
    UserDo selectOneByUsername(
            @Param("username") String username
    );
}
